package com.winning.pmph.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Table;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
@Table(name = "RELEASED_KNOWLEDGE")
public class ReleasedKnowledge extends Knowledge {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// 知识状态
	/**
	 * 已发布
	 */
	public final static int STATUS_RELEASED = 4;
	/**
	 * 未发布
	 */
	public final static int STATUS_UNRELEASED = 2;

	// 同步操作
	/**
	 * 新增
	 */
	public final static int SYNC_OPERATION_NEW = 0;
	/**
	 * 修改
	 */
	public final static int SYNC_OPERATION_MODIFY = 1;
	/**
	 * 删除
	 */
	public final static int SYNC_OPERATION_DELETE = 2;

	// 同步状态;0：待同步，1：部分同步，2：同步失败，3：已同步
	/**
	 * 待同步
	 */
	public final static int SYNC_STATUS_WAITING = 0;
	/**
	 * 部分同步
	 */
	public final static int SYNC_STATUS_PARTIAL = 1;
	/**
	 * 同步失败
	 */
	public final static int SYNC_STATUS_FAILED = 2;
	/**
	 * 已同步
	 */
	public final static int SYNC_STATUS_DONE = 3;

	/**
	 * 同步操作;0：新增，1：修改，2：删除
	 */
	@TableField(exist = false)
	private Integer syncOperation;
	/**
	 * 同步状态;0：待同步，1：部分同步，2：同步失败，3：已同步
	 */
	// update by wangchuang 20/12/28, 同步状态改为计算属性;
	@TableField(exist = false)
	private Integer syncStatus;
	@TableField(exist = false)
	private int isRevised;
	/**
	 * 推送时间
	 */
	@TableField(exist = false)
	private String operatedTime;

	@Override
	public int getStatus() {
		return 1;
	}

	public List<ReleasedKnowledgeField> getReleasedKnowledgeFieldList() {
		return JSON.parseArray(JSON.toJSONString(getKnowledgeFieldList()), ReleasedKnowledgeField.class);
	}
}